<?php
declare(strict_types=1);

namespace app\common\business;

use app\common\model\FeedbackContent as FeedbackContentModel;
use think\facade\Log;

class FeedbackContent extends CommonBase
{
    private $_feedbackContentObj = null;

    public function __construct(string $websiteCode, $name)
    {
        $this->_websiteCode        = $websiteCode;
        $this->_feedbackContentObj = new FeedbackContentModel([], $websiteCode, 'feedback_' . $name);
    }

    public function addFeedbackContent(string $formCode, array $data): array
    {
        try {
            return [self::_RESULT => $this->_feedbackContentObj->addFeedbackContent($formCode, $data), self::_MESSAGE => self::_FEEDBACK_SUCCESS_MESSAGE];
        } catch (\Exception $e) {
            logErr('添加自定义表单的留言内容失败', sprintf('websiteCode:%s,method:%s,err:%s', $this->_websiteCode, __METHOD__, $e->getMessage()));
        }

        return [self::_RESULT => false, self::_MESSAGE => self::_SYSTEM_ERROR_MESSAGE];
    }
}